package edu.rice.cs.drjava.ui;

import javax.swing.JMenu;

import junit.framework.TestCase;


/** Tests if the "Delete clean Build Directory From Project..." function  is available in Project menu.*/

public class MainFrameDeletionTest extends TestCase {
        
    private MainFrame _frame = new MainFrame();
    
    /** 
     * Tests if the "Delete clean Build Directory From Project..." function 
     * is available in project menu.
     */
    public void testProjectMenu() {
        
        boolean deleted_menu_item_exists = false;
  
        
        JMenu menu = _frame.getProjectMenu();

        
        /** search for all itens in the Project Menu */
        for (int i = 0; i < menu.getMenuComponentCount(); i++) {
            System.out.println(menu.getMenuComponent(i).getClass().getName() + " " + menu.getMenuComponent(i).getClass().getName().equalsIgnoreCase("javax.swing.JMenu$1"));
        	/** check only the menu item */
            if ( menu.getMenuComponent(i).getClass().getName().equalsIgnoreCase("javax.swing.JMenu$1")  ) {
                System.out.println(menu.getItem(i).getText() + " " + menu.getItem(i).getText().matches("Clean Build Directory"));
            	if( menu.getItem(i).getText().matches("Clean Build Directory"))
            	deleted_menu_item_exists = true;
            }
        }  
        
       
        assertTrue("Deleted Function still found!", deleted_menu_item_exists); 
        
    }
    
    
  
}
